package cm.mefobe.android.telecomcost.view;

import cm.mefobe.android.telecomcost.entities.TimeIntervall;
import cm.mefobe.android.telecomcost.entities.TimePeriod;
import android.content.Context;
import android.text.InputType;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.EditText;
import android.widget.TableRow;
import android.widget.TextView;

public class TariffingIntervallView extends TimeIntervallView {
	
	public TariffingIntervallView(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
	}

	public TariffingIntervallView(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
	}

	public TariffingIntervallView(Context context, String label) {
		super(context, label);
		// TODO Auto-generated constructor stub
	}

	@Override
	protected void setTimeIntervallView() {
		if (isInEditMode()) {
			Log.i("TariffingIntervallView", "isInEditMode");
		} else {
			if (row == null) {
				Log.i("TariffingIntervallView", "adding views...");
				row = new TableRow(_context);
				_label = new TextView(_context);
				_txtOccurences = new EditText(_context);
				periodPicker = new TimePeriodPickerView(_context);

				_label.setText("Free Time");
				_txtOccurences.setInputType(InputType.TYPE_CLASS_NUMBER);
				_txtOccurences.setText("0    ");

				row.addView(_label);
				row.addView(_txtOccurences);
				row.addView(periodPicker);

				addView(row);
				setColumnStretchable(2, true);
				setTimeIntervall(new TimeIntervall(TimePeriod.SECOND, 1));
			} else {
				Log.i("TariffingIntervallView", "TariffingIntervallView already set");
			}
		}
	}
}
